from pydantic import BaseModel, ConfigDict
from datetime import datetime


class BaseModelMixin(BaseModel):
    """基础模型混入类，提供通用的字段和配置"""
    
    model_config = ConfigDict(
        from_attributes=True,  # 支持从ORM对象创建模型实例
        arbitrary_types_allowed=True,  # 允许任意类型
        populate_by_name=True,  # 支持按名称填充字段
    )


class TimestampedModelMixin(BaseModelMixin):
    """带时间戳的模型混入类"""
    
    created_at: datetime = None
    updated_at: datetime = None


class IDModelMixin(TimestampedModelMixin):
    """带ID和时间戳的模型混入类"""
    
    id: int = None